package net.zjitc.utils;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/11/19.
 */
public class ControllerUtils {
    public static List<Class> getAllClass(String packName) throws ClassNotFoundException{
        List<Class> list = new ArrayList<Class>();
        String packPath = packName.replace(".","/");
        URL url = Thread.currentThread().getContextClassLoader().getResource(packPath);
        String filePath = url.getPath();
        File file = new File(filePath);
        File[] files = file.listFiles();
        for(File f:files){
            String fileName = f.getName();
            String clazzName = packName+"."+fileName.substring(0,fileName.length()-6);
            Class clazz = Class.forName(clazzName);
            list.add(clazz);
        }
        return list;
    }

}
